use tokio::sync::mpsc::UnboundedSender;
use crate::websockt::WebSocketFrame;

#[derive(Debug, Clone)]
pub struct WebSocketSession {
    sender: UnboundedSender<WebSocketFrame>,
}

impl WebSocketSession {
    pub fn new(sender: UnboundedSender<WebSocketFrame>) -> Self {
        Self { sender }
    }

    pub fn send_message_to_server(&self, msg: &str) {
        let _  = self.sender.send(WebSocketFrame::client_text(msg));        
    }

    pub fn send_frame_to_server(&self, frame: &WebSocketFrame) {
        let _  = self.sender.send(frame.clone());
    } 
}